﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace _queensGA
{
    public partial class frmSolution : Form
    {
        int boardLength = 8;
        int tileSize = 25;

        public frmSolution()
        {
            InitializeComponent();
        }

        private string StateToString(List<int> state)
        {
            StringBuilder sb = new StringBuilder();
            foreach (int i in state)
                sb.AppendFormat("{0} ", i);
            if (sb.Length > 0)
                sb.Remove(sb.Length - 1, 1);
            return sb.ToString();
        }

        public frmSolution(List<int> state)
        {
            InitializeComponent();
            boardLength = state.Count;
            this.Text = string.Format("A solution for N = {0}", boardLength);
            lblSolution.Text = StateToString(state);
            SetupBoard();
            cbChessBoard.SetState(state, true);
        }

        private void SetupBoard()
        {
            cbChessBoard.SetupBoard(boardLength, tileSize);
            this.Width = cbChessBoard.Width + 3 * 15;
            this.Height = cbChessBoard.Height + 4 * 15;            
        }
    }
}
